package com.societyGames.codeAlong.state
{
public class StateEnum
{
  public static const Loading:StateEnum = new StateEnum("Loading");
  public static const UserDataError:StateEnum = new StateEnum("UserDataError"); //ModuleData
  public static const FlushFailed:StateEnum = new StateEnum("FlushFailed"); //ModuleData
  public static const ShowExerciseSelect:StateEnum = new StateEnum("ShowExerciseSelect");	 //null
  public static const GoToExercise:StateEnum = new StateEnum("GoToExercise"); //moduleData:ModuleData
  public static const GoToNextExercise:StateEnum = new StateEnum("NextExercise"); //null

  //An internal display string for enum, also good for serialization.
  private var _name:String;

  //A special constructor for enum. Throws if attempted to instantiate outside of enum.
  public function StateEnum(name:String)
  {
    //If _done is true, we're instantiating after the static enum has finished, so fail.
    if (_done)
    {
      throw new Error("Cannot instantiate new enum.");
    }
    _name = name;
  }

  //Lock to indicate that static initialization is not complete.
  private static var _done:Boolean = false;

  //Static constructor
  {
    _done = true;
  }
}
}